﻿using AspDotNet.Framework.CommonLibs;
using System;
using System.Linq;
using System.Web.Mvc;

namespace AspDotNet.Framework.Mvc.FirstDemo.Controllers
{
    public class HomeController : BaseController
    {
        public override void Index()
        {
            var controllers = this.GetType().Assembly.GetTypes()
                .Where(p => p.HasParent<Controller>()/*&&!p.IsAbstract*/)
                .ToList();


            var urls = controllers
                .Select(p => $"<div><a href='{Request.Url.Scheme}://{Request.Url.Host}:{Request.Url.Port}/{p.Name.Replace(nameof(Controller), string.Empty)}' target='_blank'>{p.Name}</a></div>")
                .ToList();

            Response.Write(string.Join("", urls));

        }

        // GET: Home/Hello
        public ActionResult Hello()
        {
            ViewBag.DynamicInfo = "动态视图数据";
            return View();
        }

        // GET: Home/HelloMvc
        public ActionResult HelloMvc()
        {
            ViewBag.DynamicMessage = "这是我们的第一个MVC实例！";
            ViewBag.DynamicCurrentTime = DateTime.Now.ToString();
            return View();
        }


        [ChildActionOnly]
        public ActionResult Footer()
        {
            return PartialView("_PartialFooter2");
        }
    }
}